<?php
/**
 * Description of LoginService
 *
 * @author Magno
 */
class LoginService {


    private $loginDAO;
    function __construct() {
        $this->loginDAO = new LoginDAO();
    }


    public function salvar($login) {

        try {
            return $this->loginDAO->salvar($login);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }

    }

    public function excluir($loginID) {

        try {
            if(!isset ($loginID) || $loginID <= 0)
                throw new Exception("Codigo da Login Nao Econtrado!!!");

            $this->loginDAO->excluir($loginID);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }

    }

    public function listar($pagina = 0,$usuarioID = 0) {
        try {
            return $this->loginDAO->listar($pagina, $usuarioID);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }

    public function buscarPorID($loginID) {
        try {
            if(!isset ($loginID) || $loginID <= 0)
                throw new Exception("Codigo da Login Nao Econtrado!!!");
            return $this->loginDAO->buscarPorID($loginID);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }

    public function total($usuarioID = 0) {
        try {
            return $this->loginDAO->total($usuarioID);
        }catch(Exception $err) {
            throw new Exception($err->getMessage());
        }
    }
}
?>
